// pages/qr/to.js
const App = getApp()

Page({
  data: {
    init: false,
    url: ''
  },
  onLoad(options) {
    this.waitForReady(options)
  },
  waitForReady(options) {
    if (App.Global.OpenId) {
      this.execLoad(options)
    } else {
      setTimeout(() => {
        this.waitForReady(options)
      }, 200);
    }
  },
  goto(options) {
    let ourl = decodeURIComponent(options.q)
    this.setData({
      init: true,
      url: ourl
    })
    let t = ourl.split('?')[1].split('&')[0].split('=')[1]

    if (t === 'cb') {
      // /to/b?t=cb&clk=clkId
      let clk = ourl.split('?')[1].split('&')[1].split('=')[1]
      wx.redirectTo({
        url: `/pages/user/bind?uid=${clk}`
      })
    }
  },
})